<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/template/common/taglibs.jspf"%>
<es:contentHeader/>
<%@include file="/WEB-INF/template/common/import-zTree-css.jspf"%>

<t:base type="jquery,jquery-ui-bootstrap:bootstrap,jquery-ui-bootstrap:jquery-ui,jquery-ui-bootstrap:font-awesome"></t:base>
<t:base type="jquery-ui-bootstrap:jquery.blockUI,application"></t:base>
<link type="text/css" href="<%=request.getContextPath()%>/resources/css/icon.css?1" rel="stylesheet">
<link type="text/css" href="<%=request.getContextPath()%>/resources/css/theme/theme.blur.css?4" rel="stylesheet">

<ul class="nav nav-tabs">
    <li ${empty param['search.show_eq'] ? 'class="active"' : ''}>
        <a href="<%=request.getContextPath()%>/admin/sys/resource/tree?isShow=false&async=${not empty param.async and param.async eq true}">
            <i class="icon-table"></i>
            所有
            <i class="icon-refresh" title="点击刷新"></i>
        </a>
    </li>
    <li ${not empty param['search.show_eq'] ? 'class="active"' : ''}>
        <a href="<%=request.getContextPath()%>/admin/sys/resource/tree?isShow=true&async=${not empty param.async and param.async eq true}">
            <i class="icon-table"></i>
            显示的
        </a>
    </li>
</ul>

<es:contentFooter/>
<%@include file="/WEB-INF/template/common/import-zTree-js.jspf"%>
<script type="text/javascript">
    var async = ${not empty param.async and param.async eq true};
    $(function() {
        var zNodes =[
            <c:forEach items="${trees}" var="m">
            { id:${m.id}, pId:${m.pId}, name:"${m.name}", iconSkin:"${m.iconSkin}",open:false},
            </c:forEach>
        ];
        ctx = "<%=request.getContextPath()%>";

        var ztreeObj =$.zTree.initMovableTree({
            zNodes : zNodes,
            urlPrefix : "<%=request.getContextPath()%>/admin/sys/resource",
            async : true,
            onlyDisplayShow:${param['search.show_eq'] eq true},
            permission: <es:treePermission resourceIdentity="sys:resource"/>,
            autocomplete : {
                enable : false
            },
            setting : {
                callback : {
                    onClick: function(event, treeId, treeNode, clickFlag) {
                        parent.frames['listFrame'].location.href='<%=request.getContextPath()%>/admin/sys/resource/' + treeNode.id + "/update?async=" + async ;
                    }
                }
            }
        });

//        var zTree = $.fn.zTree.getZTreeObj(ztreeObj);
//        var nodes = zTree.getSelectedNodes();
//        zTree.expandNode(nodes[1], true, true, null, true);

    });
</script>